BX.namespace("BX.UI");BX.UI.InfoHelper={frameUrlTemplate:"",frameNode:null,popupLoader:null,availableDomainList:null,frameUrl:"",inited:false,init:function(e){if(!this.inited&&!e["availableDomainList"]){this.inited=true;BX.ajax.runAction("ui.infoHelper.getInitParams").then(function(e){this.init(e.data)}.bind(this))}else{this.inited=true;this.frameUrlTemplate=e.frameUrlTemplate||"";this.trialableFeatureList=e.trialableFeatureList||[];this.demoStatus=e.demoStatus||"UNKNOWN";this.availableDomainList=e.availableDomainList||[];BX.bind(window,"message",BX.proxy((function(e){if(!e.origin||!!e.origin&&this.availableDomainList.indexOf(e.origin)===-1){return}if(!e.data||typeof e.data!=="object"){return}if(e.data.action==="ClosePage"){this.close()}if(e.data.action==="openPage"){window.location.href=this.frameUrl}if(e.data.action==="openPageInNewTab"){window.open(this.frameUrl,"_blank")}if(e.data.action==="reloadParent"){this.reloadParent()}if(e.data.action==="openSlider"&&!!e.data.url){top.BX.SidePanel.Instance.open(e.data.url)}if(e.data.action==="openInformer"&&!!e.data.code&&!!e.data.option){top.BX.UI.InfoHelper.__showExternal(e.data.code,e.data.option)}if(e.data.action==="activateDemoSubscription"){if(e.data.licenseAgreed==="Y"){var t="/bitrix/tools/rest.php";var i=function(e){var t=BX.SidePanel.Instance.getTopSlider();if(t){BX.UI.InfoHelper.frameNode.contentWindow.postMessage({action:"onActivateDemoSubscriptionResult",result:e},"*")}}.bind(this);BX.ajax({dataType:"json",method:"POST",url:t,data:{action:"activate_demo",sessid:BX.bitrix_sessid()},onsuccess:i,onfailure:function(e,t){i({error:e+(!!t?": "+t:"")})}})}}if(e.data.action==="activateDemoLicense"){BX.ajax.runAction("ui.infoHelper.activateDemoLicense").then(function(e){var t=BX.SidePanel.Instance.getTopSlider();if(t){BX.UI.InfoHelper.frameNode.contentWindow.postMessage({action:"onActivateDemoLicenseResult",result:e},"*")}if(e.data.success==="Y"){BX.onCustomEvent("BX.UI.InfoHelper:onActivateDemoLicenseSuccess",{result:e})}}.bind(this))}if(e.data.action==="openBuySubscriptionPage"){BX.ajax.runAction("ui.infoHelper.getBuySubscriptionUrl").then(function(e){if(!!e.data&&!!e.data.url){if(e.data.action==="blank"){window.open(e.data.url,"_blank")}else if(e.data.action==="redirect"){window.location.href=e.data.url}}}.bind(this))}if(e.data.action==="activateTrialFeature"){BX.ajax.runAction("ui.infoHelper.activateTrialFeature",{data:{featureId:e.data.featureId}}).then(function(t){var i=BX.SidePanel.Instance.getTopSlider();if(i){BX.UI.InfoHelper.frameNode.contentWindow.postMessage({action:"onActivateTrialFeature",result:t},"*")}if(t.data.success==="Y"){BX.onCustomEvent("BX.UI.InfoHelper:onActivateTrialFeatureSuccess",{result:t,featureId:e.data.featureId})}}.bind(this))}}),this))}},__showExternal:function(e,t){var i=700;var a=this.getSliderId()+":"+e;var n=BX.create("iframe",{attrs:{className:"info-helper-panel-iframe",src:"about:blank"}});if(!!t&&!!t.width&&t.width>0){i=t.width}BX.SidePanel.Instance.open(a,{contentCallback:function(t){return new Promise(function(t,i){BX.ajax.runAction("ui.infoHelper.getInitParams").then(function(i){n.src=this.frameUrlTemplate.replace(/code/,e);t(BX.create("div",{attrs:{className:"info-helper-container",id:"info-helper-container"},children:[this.getLoader(),n]}))}.bind(this))}.bind(this))}.bind(this),width:i,loader:"default-loader",cacheable:false,customRightBoundary:0,events:{onLoad:function(){BX.UI.InfoHelper.showFrame(n)}}})},show:function(e,t){if(this.isOpen()){return}if(!BX.Type.isPlainObject(t)){t={}}if(!e){return}if(t.isLimit){this.sendLimitSliderAnalyticsAjax(e,t)}BX.SidePanel.Instance.open(this.getSliderId(),{contentCallback:function(i){return new Promise(function(i,a){BX.ajax.runAction("ui.infoHelper.getInitParams").then(function(a){this.init(a.data);var n=this.frameUrlTemplate.replace(/code/,e);if(t.featureId&&BX.Type.isArray(this.trialableFeatureList)){n=BX.Uri.addParam(n,{featureId:t.featureId,trialableFeatureList:this.trialableFeatureList.join(",")})}if(this.demoStatus){n=BX.Uri.addParam(n,{demoStatus:this.demoStatus})}this.frameUrl=n;if(this.getFrame().src!==this.frameUrl){this.getFrame().src=this.frameUrl}i(this.getContent())}.bind(this))}.bind(this))}.bind(this),width:700,loader:"default-loader",cacheable:false,customRightBoundary:0,events:{onCloseComplete:function(){BX.UI.InfoHelper.close()},onLoad:function(){BX.UI.InfoHelper.showFrame()},onClose:function(){BX.UI.InfoHelper.frameNode.contentWindow.postMessage({action:"onCloseWidget"},"*")}}})},sendLimitSliderAnalyticsAjax:function(e,t){var i={};var a={limits:"Y",code:e};if(t.limitAnalyticsLabels&&BX.Type.isPlainObject(t.limitAnalyticsLabels)){i=Object.assign({},t.limitAnalyticsLabels,a)}if(!i.module){console.info("Analytics labels must contain module name as a parameter!")}void BX.ajax.runAction("ui.infoHelper.showLimitSlider",{analyticsLabel:i})},close:function(){var e=this.getSlider();if(e){e.close()}},getContent:function(){if(this.content){return this.content}this.content=BX.create("div",{attrs:{className:"info-helper-container",id:"info-helper-container"},children:[this.getLoader(),this.getFrame()]});return this.content},getFrame:function(){if(this.frameNode){return this.frameNode}this.frameNode=BX.create("iframe",{attrs:{className:"info-helper-panel-iframe",src:"about:blank"}});return this.frameNode},showFrame:function(e){if(!e){e=this.getFrame()}setTimeout(function(){e.classList.add("info-helper-panel-iframe-show")}.bind(this),600)},getLoader:function(){if(this.popupLoader){return this.popupLoader}var e=new BX.Loader({target:BX("info-helper-container"),size:100});e.show();this.popupLoader=e.data.container;return this.popupLoader},getSliderId:function(){return"ui:info_helper"},getSlider:function(){return BX.SidePanel.Instance.getSlider(this.getSliderId())},reloadParent:function(){var e=false;var t=BX.SidePanel.Instance.getTopSlider();if(!!t){e=BX.SidePanel.Instance.getPreviousSlider(t)}if(!!e){e.reload()}else{window.location.reload()}return true},isOpen:function(){return this.getSlider()&&this.getSlider().isOpen()},isInited:function(){return this.inited}};
//# sourceMappingURL=info-helper.map.js